$(function(){
    cha()
})
function cha(){
    let id=$('#id').val()
    $.get(`http://localhost:3000/user/:${id}`,data=>{
        $('.pas').remove()
        data.filter(item=>{
            let html=`
            <tr class="pas">
            <td>${item.Id}</td>
            <td>${item.biaoti}</td>
            <td>${item.zhaiyao}</td>
            <td>${item.neirong}</td>
            <td>${item.fenlei}</td>
            <td>${item.zuozhe}</td>
            <td>${item.createdAt}</td>
            <td>
                <input type="button" value="修改" onclick="bian(${item.id})">
                <input type="button" value="删除" onclick="shan(${item.id})">
            </td>
            </tr>
            `
            $('#cute').append(html)
        })
    })
}

//shan
function shan(id){
    let msg=confirm('确定删除嘛?')
    if(msg){
        $.ajax({
            url:`http://localhost:3000/user/${id}`,
            type:'delete',
            success:function(res){
                cha()
                window.location.href='index.html'
            }
        })
    }
}

function add(){
    window.location.href='add.html'
}

function baocun(){
    window.location.href='index.html'
}

function quxiao(){
    window.location.href='index.html'
}

